﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class PublishApply : IAccessible<T_PublishApply, PublishApply>, ILogicEntity<T_PublishApply, PublishApply>
    {
        #region Fields
        public int Id { get; set; }
        /// <summary>
        /// 申请出版书名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 作者
        /// </summary>
        public string Authors { get; set; }
        /// <summary>
        /// 图书领域
        /// </summary>
        public string Field { get; set; }
        /// <summary>
        /// 图书介绍
        /// </summary>
        public string Introduction { get; set; }
        /// <summary>
        /// 出版方式
        /// </summary>
        public string Way { get; set; }
        /// <summary>
        /// 联系电话
        /// </summary>
        public string Phone { get; set; }
        /// <summary>
        /// 联系人
        /// </summary>
        public string Contact { get; set; }
        /// <summary>
        /// 联系邮箱
        /// </summary>
        public string Mail { get; set; }
        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime ApplyTime { get; set; }
        #endregion

        protected override void Covariant(T_PublishApply model)
        {
            Id = model.Id;
            Name = model.Name;
            Authors = model.Authors;
            Field = model.Field;
            Introduction = model.Introduction;
            Way = model.Way;
            Phone = model.Phone;
            Contact = model.Contact;
            Mail = model.Mail;
            ApplyTime = model.CreateDate;
        }

        protected override T_PublishApply Inverter(PublishApply model)
        {
            return new T_PublishApply()
            {
                Id = model.Id,
                Name = model.Name,
                Authors=model.Authors,
                Field = model.Field,
                Introduction = model.Introduction,
                Way = model.Way,
                Phone = model.Phone,
                Contact = model.Contact,
                Mail = model.Mail,
                CreateDate = model.ApplyTime
            };
        }

        public PublishApply Set(T_PublishApply dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
